<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul,
        li {
            list-style: none;
        }

        li {
            float: left;
            width: 300px;
            text-align: center;
            margin-bottom: 50px;
        }

        div {
            clear: both;
            width: 1200px;
            margin-top: 20px;
            margin-left: 30px;
            height: 300px;
            background-color: aqua;
            text-align: center;
        }

        .active {
            background: aqua;
        }
    </style>
</head>

<body>
    <ul class="nav">
        <li>内容1</li>
        <li>内容2</li>
        <li>内容3</li>
        <li>内容4</li>
    </ul>
    <div class="mmm"></div>
</body>

</html>
<script>
    var arr = [1, 2, 3, 4]
    function gets(el) { return document.querySelectorAll(el) }
    function $(el) { return document.querySelector(el) }
    class Person {
        constructor() {
            this.onclick()
        }
        onclick() {
            gets("li").forEach((item, index) => {
                item.onclick = function () {
                    gets("li").forEach((item) => {
                        item.className = ""

                    })
                    item.className = "active"
                    $('.mmm').innerHTML = arr[index]

                }
            })
        }
       
    }
    new Person()
</script>